package io.gitee.yxsnake.framework.translation.core.impl;

import io.gitee.yxsnake.framework.core.utils.ResultUtils;
import io.gitee.yxsnake.framework.system.api.RemoteUserService;
import io.gitee.yxsnake.framework.translation.annotation.TranslationType;
import io.gitee.yxsnake.framework.translation.constant.TransConstant;
import io.gitee.yxsnake.framework.translation.core.TranslationInterface;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;

/**
 * @author snake
 * @description 用户昵称翻译实现
 * @since 2024/11/3 14:00
 */
@AllArgsConstructor
@TranslationType(type = TransConstant.USER_ID_TO_NICKNAME)
public class NicknameTranslationImpl implements TranslationInterface<String> {

    @Resource
    private RemoteUserService remoteUserService;

    @Override
    public String translation(Object key, String other) {
        if (key instanceof Long id) {
            return ResultUtils.getResultData(remoteUserService.selectNicknameByIds(id.toString()));
        } else if (key instanceof String ids) {
            return  ResultUtils.getResultData(remoteUserService.selectNicknameByIds(ids));
        }
        return null;
    }
}
